﻿using Cimbalino.Phone.Toolkit.Services;
using DepSoft.Mobile.WP8.FollwIt.Framework;
using DepSoft.Mobile.WP8.FollwIt.Framework.Interfaces;
using DepSoft.Mobile.WP8.FollwIt.Messages;
using FollwItPortable;
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Messaging;
using Microsoft.Practices.ServiceLocation;

namespace DepSoft.Mobile.WP8.FollwIt.ViewModel
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class ViewModelLocator
    {
        static ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            SimpleIoc.Default.Register<INavigationService, NavigationService>();
            SimpleIoc.Default.Register<IAsyncStorageService, AsyncStorageService>();
            SimpleIoc.Default.Register<IMessenger, LastMessageReplayMessenger>();
            SimpleIoc.Default.Register<IApplicationSettingsService, ApplicationSettingsService>();
            SimpleIoc.Default.Register<IFollwItClient>(() => new FollwItClient("p7uSxaMyAoAqN"));
            SimpleIoc.Default.Register<ISecurityService, SecurityService>();
            
            SimpleIoc.Default.Register<MainViewModel>();
            SimpleIoc.Default.Register<FollwItViewModel>();
            SimpleIoc.Default.Register<MoviesViewModel>();
            SimpleIoc.Default.Register<SeriesViewModel>();
        }

        /// <summary>
        /// Gets the Main property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public MainViewModel Main
        {
            get { return ServiceLocator.Current.GetInstance<MainViewModel>(); }
        }

        public FollwItViewModel FollwIt
        {
            get { return ServiceLocator.Current.GetInstance<FollwItViewModel>(); }
        }

        public MoviesViewModel Movies
        {
            get { return ServiceLocator.Current.GetInstance<MoviesViewModel>(); }
        }

        public SeriesViewModel Series
        {
            get { return ServiceLocator.Current.GetInstance<SeriesViewModel>(); }
        }

        /// <summary>
        /// Cleans up all the resources.
        /// </summary>
        public static void Cleanup()
        {
        }
    }
}